#include <bits/stdc++.h>// 40 pts
using namespace std;

const int N = 1e5 + 5, M = 1e5 + 5, LEN = 1e6 + 5;
int T;
int n, m, L, V;
bool len[LEN];
int l[LEN];

int main () {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    cin >> T;
    while (T--) {
        cin >> n >> m >> L >> V;
        memset (l, 0, sizeof(l));
        memset (len, false, sizeof(len));
        for (int i = 1; i <= n; i++) {
            int d, a, v;
            cin >> d >> v >> a;
            if (a == 0) {
                if (v > V) l[d]++;
            }
            else if (a > 0) {
                if (v > V) {
                    l[d]++;
                    continue;
                }
                int fz = (V * V) - (v * v);
                int fm = 2 * a;
                int over_v = fz / fm;
                over_v++;
                if (d + over_v <= L) l[over_v + d]++;
            }
        }
        for (int i = 1; i<= m; i++) {
            int p;
            cin >> p;
            len[p] = true;
        }
        for (int i = 1; i <= L; i++) {
            l[i] += l[i - 1];
        }
        int Maxx = 0;
        for (int i = L; i >= 0; i--) {
            if (len[i]) {
                Maxx = l[i];
                break;
            }
        }
        cout << Maxx << " " << m - min(Maxx, 1) << endl;
    }/**/
    return 0;
}